package com.example.yang.samapp;

import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;


public class MainActivity extends RelativeLayout {


    private String vacationText, travallyText, swimmingText;

    public MainActivity(Context context) {
        this(context, null);
    }

    public MainActivity(Context context, AttributeSet attr) {
        this(context, attr, 0);
    }

    public MainActivity(Context context, AttributeSet attr, int defStyleattr) {
        super(context, attr, defStyleattr);
        View inflate = View.inflate(context, R.layout.activity_main, this);

        TypedArray ma = context.obtainStyledAttributes(attr, R.styleable.MainActivity);
        vacationText = ma.getString(R.styleable.MainActivity_vacationText);
        travallyText = ma.getString(R.styleable.MainActivity_travallyText);
        swimmingText = ma.getString(R.styleable.MainActivity_swimmingText);
        ma.recycle();


        TextView vacation = (TextView) findViewById(R.id.vacation_btn);
        TextView travally = (TextView) findViewById(R.id.travally_tv);
        TextView swimming = (TextView) findViewById(R.id.swimming_btn);

        if (vacation != null) vacation.setText(vacationText);
        if (travally != null) travally.setText(travallyText);
        if (swimming != null) swimming.setText(swimmingText);
    }

    private void init() {

    }
}
